<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>" />
<title><?php echo $title; ?> - 下载地址列表_<?php echo $cfg_webname;?></title>
<link rel="shortcut icon" href="<?php echo $cfg_cmsurl; ?>/favicon.ico" />
<link href="<?php echo $cfg_skin; ?>/css/common.css" rel="stylesheet" type="text/css" media="screen" />
<link href="<?php echo $cfg_skin; ?>/css/dede58.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="<?php echo $cfg_skin; ?>/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="<?php echo $cfg_skin; ?>/js/main.js"></script>
</head>
<style>
a, a img, input, textarea{padding: 0;border: none;color: #424242;text-decoration: none;font-family: 微软雅黑, 宋体, Verdana, Geneva, sans-serif;font-size: 12px;}
</style>
<body>
<!-- head -->
<?php pasterTempletDiy("head.htm"); ?>
<!-- head End -->
<div class="dows-list-box">
<?php
//会员
$member = $dsql->GetOne("select * from #@__member where mid='".$cfg_ml->M_ID."'");//
$memberup = $member['uptime']+$member['exptime']*3600*24;
$mrank = $member['rank'];
$time=time();

if($mrank>10){
  $sql = "SELECT aid,money FROM `#@__member_operation` WHERE arcid='".$aid."' AND mid='".$cfg_ml->M_ID."'";
}else{
  $sql = "SELECT aid,money FROM `#@__member_operation` WHERE vip=0 and arcid='".$aid."' AND mid='".$cfg_ml->M_ID."'";
}

$row = $dsql->GetOne($sql);

//素材 精品不受下载次数限制
$arc = $dsql->GetOne("select goods from #@__addonsoft where aid='$aid'");//查询模板是否为精品 

//会员级别
$rank = $dsql->GetOne("select * from #@__arcrank where rank='$mrank'");//查询
$rankdownum=$rank['downum'];

//下载需要会员级别
$needrank = $dsql->GetOne("select * from #@__arcrank where rank='".$dow['daccess']."'");//查询

if($cfg_ml->M_ID==0){?>
    <div class="dow-msg-err">
        <h1>对不起，出错了</h1>
        <p>您还没有登录，请先<a href="<?php echo $cfg_memberurl;?>/login.php">登录</a></p>
    </div>
<?php } else if($cfg_ml->isAdmin==1){?>
    <div class="dow-msg">
        <h1>您是管理员，下载不会扣费</h1>
        <p>特权：您是管理员，享免费特权，请下载</p>
    </div>
<?php } else if($cfg_ml->M_ID==$mid){?>
    <div class="dow-msg">
        <h1>您是该资源的作者，下载不会扣费</h1>
        <p>特权：您是该资源的作者，享免费特权，请下载</p>
    </div>
<?php }else if($dow['needmoney']==0){
    if($dow['daccess']>10){
?>
        <?php if($memberup >= $time && $mrank>=$dow['daccess']){?>
        <div class="dow-msg">
            <h1>您是<?php echo $rank['membername'];?>，下载不会扣费</h1>
            <p>特权：您是
                <?php echo $rank['membername'];?>，享免费特权，请下载</p>
        </div>
        <?php } else {?>
        <div class="dow-msg-err">
            <h1>对不起，出错了</h1>
            <p>您的会员权限不够</p>
        </div>
        <?php }?>
    <?php }else { ?>
    <div class="dow-msg">
        <h1>该素材为免费资源，请下载</h1>
        <p>特权：免费资源不会扣取您的寻币，请下载</p>
    </div>
<?php } }else if($memberup >= $time && $mrank>=$dow['daccess'] && $dow['daccess']>10){?>
    <div class="dow-msg">
        <h1>您是<?php echo $rank['membername'];?>，下载不会扣费</h1>
        <p>特权：您是
            <?php echo $rank['membername'];?>，享免费特权，请下载</p>
    </div>
<?php }else if(is_array($row)){?>
    <div class="dow-msg" style="background-position:236px -100px;">
        <h1>您下载过该素材，多次下载不再扣费</h1>
        <p>特权：您下载过该素材，多次下载不再扣费，请下载</p>
    </div>
<?php }else if($cfg_ml->M_Money >= $dow['needmoney']){?>
    <div class="dow-msg">
        <h1>恭喜您，支付成功！请下载</h1>
        <p>特权：金币扣取成功后，下次下载不再扣费</p>
    </div>
<?php }else{?>
    <div class="dow-msg-err">
        <h1>对不起，出错了</h1>
        <p>您的金币不足，请先<a href="<?php echo $cfg_memberurl;?>/buy.php">充值</a></p>
    </div>
<?php }?>
    <div class="arc-cont">
        <div class="float_l">
            <p><a href='<?php echo $arcurl; ?>' title='<?php echo $title; ?>'><img src="<?php echo $litpic;?>" /></a></p>
            <p class="arc-titles"><a href='<?php echo $arcurl; ?>' title='<?php echo $title; ?>'><?php echo $title; ?></a></p>
        </div>
<?php 
$sql = "SELECT aid,money FROM `#@__member_operation` WHERE vip=0 and money<>0 and arcid='".$aid."' AND mid='".$cfg_ml->M_ID."'";
$row = $dsql->GetOne($sql);
$st=strtotime(date('Y-m-d',time()) ."00:00:00");
$ed=strtotime(date('Y-m-d',time()) ."23:59:59");
$sqlnum = "SELECT count(*) as num FROM `#@__member_dows` WHERE mid='".$cfg_ml->M_ID."' and (money <> 0 or money like '%vipdown%') and ( addtime > $st and addtime < $ed)";//下载次数
$rownum = $dsql->GetOne($sqlnum);
$downum=$rownum['num'];

if($cfg_ml->M_ID == 0){?>
        <div class="dow-list-likes">
            <h1>错误提示：</h1>
            <ul class="err">
                <p>您还没有登录，不能下载，请先<a href="<?php echo $cfg_memberurl;?>/login.php">登录</a></p>
            </ul>
        </div>
<?php }else if( $dow['needmoney']==0 && $mrank < $dow['daccess'] && $cfg_ml->isAdmin==0 && $cfg_ml->M_ID!=$mid ){?>
        <div class="dow-list-likes">
            <h1>错误提示：</h1>
            <ul class="err">
                <p>您是
                    <?php echo $rank['membername'];?>，无权下载，<br>请先升级到
                    <?php echo $needrank['membername']?> <a href="<?php echo $cfg_memberurl;?>/buy.php">点击升级VIP会员</a></p>
            </ul>
        </div>
        <?php }else if(($dow['needmoney']>0 || ($dow['needmoney']==0 && $dow['daccess']>10)) && ($dow['goods']==0) && ($mrank>10) && ($downum>=$rankdownum) && $rankdownum >0){?>
        <div class="dow-list-likes">
            <h1>错误提示：</h1>
            <ul class="err">
                <p>您今日的下载次数已用完，请升级更高级别的会员享受更多下载次数</p>
            </ul>
        </div>
        <?php }else if((($memberup >=$time) && $mrank >=$dow['daccess'] && $dow['daccess']>10) || ($cfg_ml->M_Money >= $dow['needmoney'] && ($dow['needmoney']>0)) || is_array($row) || ($cfg_ml->isAdmin==1) || ($cfg_ml->M_ID==$mid) || ($dow['daccess']<=10 && $dow['needmoney']==0)){?>
        <div class="dow-list-likes">
            <h1>下载地址：</h1>
            <ul>
                <?php if($dow['pan_baidu']!=''){?>
                <li class="pan-baidu"><a href="<?php echo 'download.php?open=2&type=baidu&id='.$aid.'&uhash='.substr(md5(preg_replace("/\s/","",$dow['pan_baidu'])), 0, 24)?>" target="_blank">百度云盘</a> <span>提取密码：<i><?php echo $dow['pan_baidu_mima']?></i></span></li>
                <?php } ?>
                <?php if($dow['softurl1']!=''){?>
                <li class="pan-baidu"><a href="<?php echo 'download.php?open=2&type=local&id='.$aid.'&uhash='.substr(md5(preg_replace("/\s/","",$dow['softurl1'])), 0, 24)?>" target="_blank">本地下载</a></li>
                <?php } ?>
            </ul>
            <!-- <h1 class="dows-pwd-title"></h1> -->
        </div>
        <?php }else if(!is_array($row) && $cfg_ml->M_Money < $dow['needmoney']){?>
        <div class="dow-list-likes">
            <h1>错误提示：</h1>
            <ul class="err">
                <p>您的寻币不足，请先<a href="<?php echo $cfg_memberurl;?>/buy.php">充值</a></p>
            </ul>
        </div>
        <?php }?>
    </div>
</div>
<div class="back">
    <a href="<?php echo $cfg_cmsurl;?>/" class="home">返回首页</a>
    <a href="<?php echo $arcurl;?>" class="arcurl">返回上一页</a>
</div>
</body>
</html>
